    module types_generic
      use precisions
      use globalvalues
      

      type typeGrids
          integer :: maxA, retireAge 
          integer :: maxT, cPoints, maxYY, maxYO, annPoints 
          real (kind=rk) :: assMin, assMax
          real (kind=rk) :: A(assGlob, yearsGlob+1)
          real (kind=rk) :: YOld(incOGlob, retireAgeGlob:yearsGlob+1), YYoung(incYGlob, 1:(retireAgeGlob-1))
          real (kind=rk) :: c(consGridGlob), ann(annPointsGlob)
      end type typeGrids
      
      type typeVal
        real (kind=rk) :: vYoungNoAccess(assGlob, 1, incYGlob, 1:(retireAgeGlob-1))         
        real (kind=rk) :: vOldNoAccess(assGlob, 1, incOGlob, retireAgeGlob:yearsGlob+1) 
      end type typeVal
      
      
      type typePol
        real (kind=rk) :: cYoungNoAccess(assGlob, 1, incYGlob, 1:(retireAgeGlob-1))         
        real (kind=rk) :: cOldNoAccess(assGlob, 1, incOGlob, retireAgeGlob:yearsGlob+1) 
      end type typePol
      
      type typeValPol
        type(typeVal) :: val    
      end type typeValPol
      
      
      type typeParams
         real (kind=rk) :: gamma
         real (kind=rk) :: beta  
         real (kind=rk) :: OneMinusGamma
         real (kind=rk) :: freeMinCons
         
         ! Housing
         real (kind=rk) :: imputedRentForUtil
      end type typeParams
          
     type typeReadInParams
         real (kind=rk) :: gamma
         real (kind=rk) :: beta
         logical :: obj, addMinLoad, housing, annOn, unscaled, discreteAnn
     end type typeReadInParams
    
     
  


  
        type typeAllInputs
            real (kind=rk) :: weibullK, weibullLam
            integer :: age
            real (kind=rk) :: objectiveAnn
            integer :: id
            real (kind=rk) :: statePen, Assets
            real (kind=rk), dimension(51) :: hazards, hazardsUnscaled
            real (kind=rk) :: imputedRent
        end type typeAllInputs     
     
      type typeTech
          real (kind=rk) :: r 
          real (kind=rk) :: surv(yearsGlob), survObj(yearsGlob), survObjUnscaled(yearsGlob)
          logical :: survProbOn 
          integer :: retireAge, ageForAnn, maxT 
          real (kind=rk) :: annAdminLoad, annRates(yearsGlob),  annRateSubjForPrinting(yearsGlob)

          
          logical :: annOn, adjustBeq, stochInc, SSOn
          real (kind=rk) :: SSlevel
          
  
          integer :: ageAtSurvey
          type(typeAllInputs) :: allIn(numpeeps)
          real (kind=rk) :: annRatesAll(yearsGlob,numpeeps, 2, 2) ! The penultimate dimension is fair/unfair, the last is scaled unscaled
          real (kind=rk) :: annRatesSubj(yearsGlob,numpeeps) ! Subjective Annuity Rate Just for printing
          real (kind=rk) :: survProbAll(yearsGlob, numpeeps),  survProbAllObj(yearsGlob, numpeeps), survProbAllObjUnscaled(yearsGlob, numpeeps)
          integer :: id
          logical :: housing, addLoadOn, obj, unscaled, discreteAnn
      end type typeTech
        
      
      type typeInfoForMax
          real (kind=rk) :: cashOnHand, ixA
          real (kind=rk) ::  Y, annY, Y1, Y1Def
          integer :: today, tomorrow, ixY
          logical :: solveT_SimF
      end type typeInfoForMax

      type typeForOptRout
          real (kind=rk) :: leftoverA,  annPot, Y1,  AssetForLiqOrCon 
          !logical :: PCpaidOpt
          integer :: ixAnn
      end type typeForOptRout
      
      type typeInfoForSim
          real (kind=rk) :: today
          real (kind=rk) :: startA
      end type typeInfoForSim
      
      
      type typeProfiles
            real (kind=rk), dimension(yearsGlob, numSimsGlob) :: cons, assStart, assEnd, annY, Y, annW, totW, totLiqW, val 
            real (kind=rk), dimension(yearsGlob, numSimsGlob) ::vsl,   assLocStartReal, assLocEndReal 
            real (kind=rk) :: annProp(yearsGlob, numSimsGlob) ! This does not need to be every year but just easier with my templates etc
            real (kind=highprecintkind), dimension(yearsGlob) :: consMean, assStartMean, assEndMean, annYMean, YMean, annWMean, totWMean, totLiqWMean
            real (kind=highprecintkind), dimension(yearsGlob) :: valMean !, assForBeqMean, transShockMean
            real (kind=highprecintkind), dimension(yearsGlob) :: consSD, assStartSD, assEndSD, annYSD, YSD, annWSD, totWSD, totLiqWSD 
            real (kind=highprecintkind), dimension(yearsGlob) :: valSD 
            real (kind=highprecintkind) :: annPropMean(yearsGlob), annPropSD(yearsGlob) ! This does not need to be every year but just easier with my templates etc
            
            integer, dimension(yearsGlob, numSimsGlob) ::   assLocStart, assLocEnd
            ! Objects for estimation:
            real (kind=rk) :: medBeq90, topQbeq90, ass45, vsl45, partRate60
            real (kind=highprecintkind) :: assForBeqQuants(2,yearsGlob)
      end type typeProfiles
      
       type typeProfilesAnn
            real (kind=rk), dimension(yearsGlob, numPeeps) :: cons, assStart, assEnd, Y, val 
            real (kind=rk) :: annProp(yearsGlob, numPeeps) ! This does not need to be every year but just easier with my templates etc            
            real (kind=highprecintkind), dimension(yearsGlob) :: consMean, assStartMean, assEndMean, YMean, valMean
            real (kind=highprecintkind) :: annPropMean(yearsGlob)
            real (kind=highprecintkind), dimension(yearsGlob) :: consSD, assStartSD, assEndSD, YSD, valSD
            real (kind=highprecintkind) :: annPropSD(yearsGlob)
       end type typeProfilesAnn
           
      type typeSim
            integer :: numSims
            real (kind=rk) :: startA
      end type typeSim
      

      
      
    end module types_generic
